/**
 * @ngdoc app services
 * @name appServices
 * @description
 * # Application_NG：应用程序服务
 */
(function () {
    'use strict';
    appModule.service('appServices', [
        'functionServices',
        function (functionServices) {
            //http错误提示
            this.httpErrorAlert = function (error) {
                console.log('appServices', error);
                var title = error ? error.data.error.message : '网络异常，请联系管理员！',
                    text = error ? error.data.error.details : null,
                    reloadPage = false;//重载页面（刷新）
                //转换英文为中文
                switch (title) {
                    case 'Current user did not login to the application!':
                        title = '当前用户没有登录到应用程序！';
                        reloadPage = true;
                        break;
                    case 'Login failed!':
                        title = '登录失败！（' + text + '）';
                        break;
                    case 'Your request is not valid!':
                        title = '请求无效！';
                        break;
                }
                switch (text) {
                    case 'Invalid user name or password':
                        text = '无效的用户名或密码。';
                        break;
                }
                //弹窗提示控件配置
                sweetAlert(
                    {
                        title: title,//头部
                        text: text,//主体
                        type: "error",//类型
                        // confirmButtonColor: "#286090",//确认按钮颜色
                        confirmButtonText: "关闭",//确认按钮文本
                    },
                    function (isConfirm) {
                        if (isConfirm && reloadPage) {//确认
                            location.reload();
                        }
                    }
                );

            };
        }
    ]);
})();